/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cageballtv;

import cageballcommon.io.impl.CageballFileReader;
import cageballcommon.io.impl.CageballSocketReader;
import cageballcommon.io.interfaces.CageballReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author kanonas
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {

            Properties conf = new Properties();

            conf.load(new FileInputStream("tv.properties"));

            String ip = conf.getProperty("ip");
            int port = Integer.parseInt(conf.getProperty("port"));
            int bufferSize = Integer.parseInt(conf.getProperty("bufferSize"));

            CageballReader reader = new CageballSocketReader(new Socket(ip, port));
            //CageballReader reader = new CageballFileReader(new File("game1.txt"));

            StateReceiver stateReceiver = new StateReceiver(reader, bufferSize);
            new Thread(stateReceiver).start();

            Visualizer visualizer = new Visualizer(stateReceiver);
            new Thread(visualizer).start();

        } catch (UnknownHostException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
